/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package intelligenttm.InPutDlg;

import intelligenttm.SourceFile.CartoType;
import intelligenttm.SourceFile.FenQuCartoType;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.event.EventType;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.MenuButton;
import javafx.scene.control.MenuItem;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;

/**
 * FXML Controller class
 *
 * @author 望舒凌霄
 */
public class AddNewFenQuTypeDlgController implements Initializable {
    @FXML
    private GridPane RootPane;
    @FXML
    private MenuButton ChooseType;
    @FXML
    private Button BtnCancel;
    @FXML
    private Button BtnEnsure;
    @FXML
    private ImageView ShowSample;
    @FXML
    private MenuItem IBingZhuang;
    @FXML
    private MenuItem ITiaoXing;
    @FXML
    private MenuItem IZheXian;
    @FXML
    private MenuItem IZiDing;
    
    private FenQuCartoType FQCPType=null;
    
    /**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
        EventHandler E=new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                String Type=((MenuItem)event.getTarget()).getText();
                ChooseType.setText(Type);
                Image I=new Image("Pic/TypeSamplePic/"+Type+".jpg");
                ShowSample.setImage(I);
            }
        };
        IBingZhuang.setOnAction(E);
        ITiaoXing.setOnAction(E);
        IZheXian.setOnAction(E);
        IZiDing.setOnAction(E);
        
    }    

    @FXML
    private void HandleBtnCancel(ActionEvent event) {
        FQCPType=null;
        RootPane.getScene().getWindow().hide();
    }

    @FXML
    private void HandleBtnEnsure(ActionEvent event) {
        ImageView I=new ImageView();
        I.setImage(new Image("Pic/TypeSamplePic/"+ChooseType.getText()+".jpg"));
        FQCPType=new FenQuCartoType(ChooseType.getText(),I);
        RootPane.getScene().getWindow().hide();
    }

    public FenQuCartoType getFQCPType() {
        return FQCPType;
    }
    
    
}
